home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / libxslt / xsltInternals.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-07-28  |  55.7 KB  |  1,971 lines

  1. /*
  2.  * Summary: internal data structures, constants and functions
  3.  * Description: Internal data structures, constants and functions used
  4.  *              by the XSLT engine. 
  5.  *              They are not part of the API or ABI, i.e. they can change
  6.  *              without prior notice, use carefully.
  7.  *
  8.  * Copy: See Copyright for the status of this software.
  9.  *
  10.  * Author: Daniel Veillard
  11.  */
  12.  
  13. #ifndef __XML_XSLT_INTERNALS_H__
  14. #define __XML_XSLT_INTERNALS_H__
  15.  
  16. #include <libxml/tree.h>
  17. #include <libxml/hash.h>
  18. #include <libxml/xpath.h>
  19. #include <libxml/xmlerror.h>
  20. #include <libxml/dict.h>
  21. #include <libxml/xmlstring.h>
  22. #include <libxslt/xslt.h>
  23. #include "xsltexports.h"
  24. #include "numbersInternals.h"
  25.  
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29.  
  30. /* #define XSLT_DEBUG_PROFILE_CACHE */
  31.  
  32. /**
  33.  * XSLT_IS_TEXT_NODE:
  34.  *
  35.  * check if the argument is a text node
  36.  */
  37. #define XSLT_IS_TEXT_NODE(n) ((n != NULL) && \
  38.     (((n)->type == XML_TEXT_NODE) || \
  39.      ((n)->type == XML_CDATA_SECTION_NODE)))
  40.  
  41.  
  42. /**
  43.  * XSLT_MARK_RES_TREE_FRAG:
  44.  *
  45.  * internal macro to set up tree fragments
  46.  */
  47. #define XSLT_MARK_RES_TREE_FRAG(n) \
  48.     (n)->name = (char *) xmlStrdup(BAD_CAST " fake node libxslt");
  49.  
  50. /**
  51.  * XSLT_IS_RES_TREE_FRAG:
  52.  *
  53.  * internal macro to test tree fragments
  54.  */
  55. #define XSLT_IS_RES_TREE_FRAG(n) \
  56.     ((n != NULL) && ((n)->type == XML_DOCUMENT_NODE) && \
  57.      ((n)->name != NULL) && ((n)->name[0] == ' '))
  58.  
  59. /**
  60.  * XSLT_REFACTORED_KEYCOMP:
  61.  *
  62.  * Internal define to enable on-demand xsl:key computation.
  63.  * That's the only mode now but the define is kept for compatibility
  64.  */
  65. #define XSLT_REFACTORED_KEYCOMP
  66.  
  67. /**
  68.  * XSLT_FAST_IF:
  69.  *
  70.  * Internal define to enable usage of xmlXPathCompiledEvalToBoolean()
  71.  * for XSLT "tests"; e.g. in <xsl:if test="/foo/bar">
  72.  */
  73. #define XSLT_FAST_IF
  74.  
  75. /**
  76.  * XSLT_REFACTORED:
  77.  *
  78.  * Internal define to enable the refactored parts of Libxslt.
  79.  */
  80. /* #define XSLT_REFACTORED */
  81. /* ==================================================================== */
  82.  
  83. /**
  84.  * XSLT_REFACTORED_VARS:
  85.  *
  86.  * Internal define to enable the refactored variable part of libxslt
  87.  */
  88. #define XSLT_REFACTORED_VARS
  89.  
  90. #ifdef XSLT_REFACTORED
  91.  
  92. extern const xmlChar *xsltXSLTAttrMarker;
  93.  
  94.  
  95. /* TODO: REMOVE: #define XSLT_REFACTORED_EXCLRESNS */
  96.  
  97. /* TODO: REMOVE: #define XSLT_REFACTORED_NSALIAS */
  98.  
  99. /**
  100.  * XSLT_REFACTORED_XSLT_NSCOMP
  101.  *
  102.  * Internal define to enable the pointer-comparison of
  103.  * namespaces of XSLT elements. 
  104.  */
  105. /* #define XSLT_REFACTORED_XSLT_NSCOMP */
  106.  
  107. /**
  108.  * XSLT_REFACTORED_XPATHCOMP:
  109.  *
  110.  * Internal define to enable the optimization of the
  111.  * compilation of XPath expressions.
  112.  */
  113. #define XSLT_REFACTORED_XPATHCOMP
  114.  
  115. #ifdef XSLT_REFACTORED_XSLT_NSCOMP
  116.  
  117. extern const xmlChar *xsltConstNamespaceNameXSLT;
  118.  
  119. /**
  120.  * IS_XSLT_ELEM_FAST:
  121.  *
  122.  * quick test to detect XSLT elements
  123.  */
  124. #define IS_XSLT_ELEM_FAST(n) \
  125.     (((n) != NULL) && ((n)->ns != NULL) && \
  126.     ((n)->ns->href == xsltConstNamespaceNameXSLT))
  127.  
  128. /**
  129.  * IS_XSLT_ATTR_FAST:
  130.  *
  131.  * quick test to detect XSLT attributes
  132.  */
  133. #define IS_XSLT_ATTR_FAST(a) \
  134.     (((a) != NULL) && ((a)->ns != NULL) && \
  135.     ((a)->ns->href == xsltConstNamespaceNameXSLT))
  136.  
  137. /**
  138.  * XSLT_HAS_INTERNAL_NSMAP:
  139.  *
  140.  * check for namespace mapping
  141.  */
  142. #define XSLT_HAS_INTERNAL_NSMAP(s) \
  143.     (((s) != NULL) && ((s)->principal) && \
  144.      ((s)->principal->principalData) && \
  145.      ((s)->principal->principalData->nsMap))
  146.  
  147. /**
  148.  * XSLT_GET_INTERNAL_NSMAP:
  149.  *
  150.  * get pointer to namespace map
  151.  */
  152. #define XSLT_GET_INTERNAL_NSMAP(s) ((s)->principal->principalData->nsMap)
  153.  
  154. #else /* XSLT_REFACTORED_XSLT_NSCOMP */
  155.  
  156. /**
  157.  * IS_XSLT_ELEM_FAST:
  158.  *
  159.  * quick check whether this is an xslt element
  160.  */
  161. #define IS_XSLT_ELEM_FAST(n) \
  162.     (((n) != NULL) && ((n)->ns != NULL) && \
  163.      (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
  164.  
  165. /**
  166.  * IS_XSLT_ATTR_FAST:
  167.  *
  168.  * quick check for xslt namespace attribute
  169.  */
  170. #define IS_XSLT_ATTR_FAST(a) \
  171.     (((a) != NULL) && ((a)->ns != NULL) && \
  172.      (xmlStrEqual((a)->ns->href, XSLT_NAMESPACE)))
  173.  
  174.  
  175. #endif /* XSLT_REFACTORED_XSLT_NSCOMP */
  176.  
  177.  
  178. /**
  179.  * XSLT_REFACTORED_MANDATORY_VERSION:
  180.  *
  181.  * TODO: Currently disabled to surpress regression test failures, since
  182.  *  the old behaviour was that a missing version attribute
  183.  *  produced a only a warning and not an error, which was incerrect.
  184.  *  So the regression tests need to be fixed if this is enabled.
  185.  */
  186. /* #define XSLT_REFACTORED_MANDATORY_VERSION */
  187.  
  188. /**
  189.  * xsltPointerList:
  190.  *
  191.  * Pointer-list for various purposes.
  192.  */
  193. typedef struct _xsltPointerList xsltPointerList;
  194. typedef xsltPointerList *xsltPointerListPtr;
  195. struct _xsltPointerList {
  196.     void **items;
  197.     int number;
  198.     int size;
  199. };
  200.  
  201. #endif
  202.  
  203. /**
  204.  * XSLT_REFACTORED_PARSING:
  205.  *
  206.  * Internal define to enable the refactored parts of Libxslt
  207.  * related to parsing.
  208.  */
  209. /* #define XSLT_REFACTORED_PARSING */
  210.  
  211. /**
  212.  * XSLT_MAX_SORT:
  213.  *
  214.  * Max number of specified xsl:sort on an element.
  215.  */
  216. #define XSLT_MAX_SORT 15
  217.  
  218. /**
  219.  * XSLT_PAT_NO_PRIORITY:
  220.  *
  221.  * Specific value for pattern without priority expressed.
  222.  */
  223. #define XSLT_PAT_NO_PRIORITY -12345789
  224.  
  225. /**
  226.  * xsltRuntimeExtra:
  227.  *
  228.  * Extra information added to the transformation context.
  229.  */
  230. typedef struct _xsltRuntimeExtra xsltRuntimeExtra;
  231. typedef xsltRuntimeExtra *xsltRuntimeExtraPtr;
  232. struct _xsltRuntimeExtra {
  233.     void       *info;        /* pointer to the extra data */
  234.     xmlFreeFunc deallocate;    /* pointer to the deallocation routine */
  235.     union {            /* dual-purpose field */
  236.         void   *ptr;        /* data not needing deallocation */
  237.     int    ival;        /* integer value storage */
  238.     } val;
  239. };
  240.  
  241. /**
  242.  * XSLT_RUNTIME_EXTRA_LST:
  243.  * @ctxt: the transformation context
  244.  * @nr: the index
  245.  *
  246.  * Macro used to access extra information stored in the context
  247.  */
  248. #define XSLT_RUNTIME_EXTRA_LST(ctxt, nr) (ctxt)->extras[(nr)].info
  249. /**
  250.  * XSLT_RUNTIME_EXTRA_FREE:
  251.  * @ctxt: the transformation context
  252.  * @nr: the index
  253.  *
  254.  * Macro used to free extra information stored in the context
  255.  */
  256. #define XSLT_RUNTIME_EXTRA_FREE(ctxt, nr) (ctxt)->extras[(nr)].deallocate
  257. /**
  258.  * XSLT_RUNTIME_EXTRA:
  259.  * @ctxt: the transformation context
  260.  * @nr: the index
  261.  *
  262.  * Macro used to define extra information stored in the context
  263.  */
  264. #define    XSLT_RUNTIME_EXTRA(ctxt, nr, typ) (ctxt)->extras[(nr)].val.typ
  265.  
  266. /**
  267.  * xsltTemplate:
  268.  *
  269.  * The in-memory structure corresponding to an XSLT Template.
  270.  */
  271. typedef struct _xsltTemplate xsltTemplate;
  272. typedef xsltTemplate *xsltTemplatePtr;
  273. struct _xsltTemplate {
  274.     struct _xsltTemplate *next;/* chained list sorted by priority */
  275.     struct _xsltStylesheet *style;/* the containing stylesheet */
  276.     xmlChar *match;    /* the matching string */
  277.     float priority;    /* as given from the stylesheet, not computed */
  278.     const xmlChar *name; /* the local part of the name QName */
  279.     const xmlChar *nameURI; /* the URI part of the name QName */
  280.     const xmlChar *mode;/* the local part of the mode QName */
  281.     const xmlChar *modeURI;/* the URI part of the mode QName */
  282.     xmlNodePtr content;    /* the template replacement value */
  283.     xmlNodePtr elem;    /* the source element */
  284.  
  285.     /*
  286.     * TODO: @inheritedNsNr and @inheritedNs won't be used in the
  287.     *  refactored code.
  288.     */
  289.     int inheritedNsNr;  /* number of inherited namespaces */
  290.     xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */
  291.  
  292.     /* Profiling informations */
  293.     int nbCalls;        /* the number of time the template was called */
  294.     unsigned long time; /* the time spent in this template */
  295.     void *params;       /* xsl:param instructions */
  296. };
  297.  
  298. /**
  299.  * xsltDecimalFormat:
  300.  *
  301.  * Data structure of decimal-format.
  302.  */
  303. typedef struct _xsltDecimalFormat xsltDecimalFormat;
  304. typedef xsltDecimalFormat *xsltDecimalFormatPtr;
  305. struct _xsltDecimalFormat {
  306.     struct _xsltDecimalFormat *next; /* chained list */
  307.     xmlChar *name;
  308.     /* Used for interpretation of pattern */
  309.     xmlChar *digit;
  310.     xmlChar *patternSeparator;
  311.     /* May appear in result */
  312.     xmlChar *minusSign;
  313.     xmlChar *infinity;
  314.     xmlChar *noNumber; /* Not-a-number */
  315.     /* Used for interpretation of pattern and may appear in result */
  316.     xmlChar *decimalPoint;
  317.     xmlChar *grouping;
  318.     xmlChar *percent;
  319.     xmlChar *permille;
  320.     xmlChar *zeroDigit;
  321. };
  322.  
  323. /**
  324.  * xsltDocument:
  325.  *
  326.  * Data structure associated to a parsed document.
  327.  */
  328. typedef struct _xsltDocument xsltDocument;
  329. typedef xsltDocument *xsltDocumentPtr;
  330. struct _xsltDocument {
  331.     struct _xsltDocument *next;    /* documents are kept in a chained list */
  332.     int main;            /* is this the main document */
  333.     xmlDocPtr doc;        /* the parsed document */
  334.     void *keys;            /* key tables storage */
  335.     struct _xsltDocument *includes; /* subsidiary includes */
  336.     int preproc;        /* pre-processing already done */
  337.     int nbKeysComputed;
  338. };
  339.  
  340. /**
  341.  * xsltKeyDef:
  342.  *
  343.  * Representation of an xsl:key.
  344.  */
  345. typedef struct _xsltKeyDef xsltKeyDef;
  346. typedef xsltKeyDef *xsltKeyDefPtr;
  347. struct _xsltKeyDef {
  348.     struct _xsltKeyDef *next;
  349.     xmlNodePtr inst;
  350.     xmlChar *name;
  351.     xmlChar *nameURI;
  352.     xmlChar *match;
  353.     xmlChar *use;
  354.     xmlXPathCompExprPtr comp;
  355.     xmlXPathCompExprPtr usecomp;
  356.     xmlNsPtr *nsList;           /* the namespaces in scope */
  357.     int nsNr;                   /* the number of namespaces in scope */
  358. };
  359.  
  360. /**
  361.  * xsltKeyTable:
  362.  *
  363.  * Holds the computed keys for key definitions of the same QName.
  364.  * Is owned by an xsltDocument.
  365.  */
  366. typedef struct _xsltKeyTable xsltKeyTable;
  367. typedef xsltKeyTable *xsltKeyTablePtr;
  368. struct _xsltKeyTable {
  369.     struct _xsltKeyTable *next;
  370.     xmlChar *name;
  371.     xmlChar *nameURI;
  372.     xmlHashTablePtr keys;
  373. };
  374.  
  375. /*
  376.  * The in-memory structure corresponding to an XSLT Stylesheet.
  377.  * NOTE: most of the content is simply linked from the doc tree
  378.  *       structure, no specific allocation is made.
  379.  */
  380. typedef struct _xsltStylesheet xsltStylesheet;
  381. typedef xsltStylesheet *xsltStylesheetPtr;
  382.  
  383. typedef struct _xsltTransformContext xsltTransformContext;
  384. typedef xsltTransformContext *xsltTransformContextPtr;
  385.  
  386. /**
  387.  * xsltElemPreComp:
  388.  *
  389.  * The in-memory structure corresponding to element precomputed data,
  390.  * designed to be extended by extension implementors.
  391.  */
  392. typedef struct _xsltElemPreComp xsltElemPreComp;
  393. typedef xsltElemPreComp *xsltElemPreCompPtr;
  394.  
  395. /**
  396.  * xsltTransformFunction:
  397.  * @ctxt: the XSLT transformation context
  398.  * @node: the input node
  399.  * @inst: the stylesheet node
  400.  * @comp: the compiled information from the stylesheet
  401.  *
  402.  * Signature of the function associated to elements part of the
  403.  * stylesheet language like xsl:if or xsl:apply-templates.
  404.  */
  405. typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt,
  406.                                    xmlNodePtr node,
  407.                        xmlNodePtr inst,
  408.                            xsltElemPreCompPtr comp);
  409.  
  410. /**
  411.  * xsltSortFunc:
  412.  * @ctxt:    a transformation context
  413.  * @sorts:   the node-set to sort
  414.  * @nbsorts: the number of sorts
  415.  *
  416.  * Signature of the function to use during sorting
  417.  */
  418. typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
  419.                   int nbsorts);
  420.  
  421. typedef enum {
  422.     XSLT_FUNC_COPY=1,
  423.     XSLT_FUNC_SORT,
  424.     XSLT_FUNC_TEXT,
  425.     XSLT_FUNC_ELEMENT,
  426.     XSLT_FUNC_ATTRIBUTE,
  427.     XSLT_FUNC_COMMENT,
  428.     XSLT_FUNC_PI,
  429.     XSLT_FUNC_COPYOF,
  430.     XSLT_FUNC_VALUEOF,
  431.     XSLT_FUNC_NUMBER,
  432.     XSLT_FUNC_APPLYIMPORTS,
  433.     XSLT_FUNC_CALLTEMPLATE,
  434.     XSLT_FUNC_APPLYTEMPLATES,
  435.     XSLT_FUNC_CHOOSE,
  436.     XSLT_FUNC_IF,
  437.     XSLT_FUNC_FOREACH,
  438.     XSLT_FUNC_DOCUMENT,
  439.     XSLT_FUNC_WITHPARAM,
  440.     XSLT_FUNC_PARAM,
  441.     XSLT_FUNC_VARIABLE,
  442.     XSLT_FUNC_WHEN,
  443.     XSLT_FUNC_EXTENSION
  444. #ifdef XSLT_REFACTORED
  445.     ,
  446.     XSLT_FUNC_OTHERWISE,
  447.     XSLT_FUNC_FALLBACK,
  448.     XSLT_FUNC_MESSAGE,
  449.     XSLT_FUNC_INCLUDE,
  450.     XSLT_FUNC_ATTRSET,
  451.     XSLT_FUNC_LITERAL_RESULT_ELEMENT,
  452.     XSLT_FUNC_UNKOWN_FORWARDS_COMPAT
  453. #endif
  454. } xsltStyleType;
  455.  
  456. /**
  457.  * xsltElemPreCompDeallocator:
  458.  * @comp:  the #xsltElemPreComp to free up
  459.  *
  460.  * Deallocates an #xsltElemPreComp structure.
  461.  */
  462. typedef void (*xsltElemPreCompDeallocator) (xsltElemPreCompPtr comp);
  463.  
  464. /**
  465.  * xsltElemPreComp:
  466.  *
  467.  * The basic structure for compiled items of the AST of the XSLT processor.
  468.  * This structure is also intended to be extended by extension implementors.
  469.  * TODO: This is somehow not nice, since it has a "free" field, which
  470.  *   derived stylesheet-structs do not have.
  471.  */
  472. struct _xsltElemPreComp {
  473.     xsltElemPreCompPtr next;        /* next item in the global chained
  474.                        list hold by xsltStylesheet. */
  475.     xsltStyleType type;        /* type of the element */
  476.     xsltTransformFunction func;     /* handling function */
  477.     xmlNodePtr inst;            /* the node in the stylesheet's tree
  478.                        corresponding to this item */
  479.  
  480.     /* end of common part */
  481.     xsltElemPreCompDeallocator free;    /* the deallocator */
  482. };
  483.  
  484. /**
  485.  * xsltStylePreComp:
  486.  *
  487.  * The abstract basic structure for items of the XSLT processor.
  488.  * This includes:
  489.  * 1) compiled forms of XSLT instructions (xsl:if, xsl:attribute, etc.)
  490.  * 2) compiled forms of literal result elements
  491.  * 3) compiled forms of extension elements
  492.  */
  493. typedef struct _xsltStylePreComp xsltStylePreComp;
  494. typedef xsltStylePreComp *xsltStylePreCompPtr;
  495.  
  496. #ifdef XSLT_REFACTORED
  497.  
  498. /*
  499. * Some pointer-list utility functions.
  500. */
  501. XSLTPUBFUN xsltPointerListPtr XSLTCALL
  502.         xsltPointerListCreate        (int initialSize);
  503. XSLTPUBFUN void XSLTCALL
  504.         xsltPointerListFree        (xsltPointerListPtr list);
  505. XSLTPUBFUN void XSLTCALL
  506.         xsltPointerListClear        (xsltPointerListPtr list);
  507. XSLTPUBFUN int XSLTCALL
  508.         xsltPointerListAddSize        (xsltPointerListPtr list,                         
  509.                          void *item,
  510.                          int initialSize);
  511.  
  512. /************************************************************************
  513.  *                                    *
  514.  * Refactored structures                                                *
  515.  *                                    *
  516.  ************************************************************************/
  517.  
  518. typedef struct _xsltNsListContainer xsltNsListContainer;
  519. typedef xsltNsListContainer *xsltNsListContainerPtr;
  520. struct _xsltNsListContainer {
  521.     xmlNsPtr *list;
  522.     int totalNumber;
  523.     int xpathNumber;    
  524. };
  525.  
  526. /**
  527.  * XSLT_ITEM_COMPATIBILITY_FIELDS:
  528.  * 
  529.  * Fields for API compatibility to the structure
  530.  * _xsltElemPreComp which is used for extension functions.
  531.  * Note that @next is used for storage; it does not reflect a next
  532.  * sibling in the tree.
  533.  * TODO: Evaluate if we really need such a compatibility.
  534.  */
  535. #define XSLT_ITEM_COMPATIBILITY_FIELDS \
  536.     xsltElemPreCompPtr next;\
  537.     xsltStyleType type;\
  538.     xsltTransformFunction func;\
  539.     xmlNodePtr inst;
  540.  
  541. /**
  542.  * XSLT_ITEM_NAVIGATION_FIELDS:
  543.  *
  544.  * Currently empty.
  545.  * TODO: It is intended to hold navigational fields in the future.
  546.  */
  547. #define XSLT_ITEM_NAVIGATION_FIELDS
  548. /*
  549.     xsltStylePreCompPtr parent;\
  550.     xsltStylePreCompPtr children;\
  551.     xsltStylePreCompPtr nextItem; 
  552. */
  553.  
  554. /**
  555.  * XSLT_ITEM_NSINSCOPE_FIELDS:
  556.  *
  557.  * The in-scope namespaces.
  558.  */
  559. #define XSLT_ITEM_NSINSCOPE_FIELDS xsltNsListContainerPtr inScopeNs;
  560.  
  561. /**
  562.  * XSLT_ITEM_COMMON_FIELDS:
  563.  *
  564.  * Common fields used for all items.
  565.  */
  566. #define XSLT_ITEM_COMMON_FIELDS \
  567.     XSLT_ITEM_COMPATIBILITY_FIELDS \
  568.     XSLT_ITEM_NAVIGATION_FIELDS \
  569.     XSLT_ITEM_NSINSCOPE_FIELDS
  570.  
  571. /**
  572.  * _xsltStylePreComp: 
  573.  *
  574.  * The abstract basic structure for items of the XSLT processor.
  575.  * This includes:
  576.  * 1) compiled forms of XSLT instructions (e.g. xsl:if, xsl:attribute, etc.)
  577.  * 2) compiled forms of literal result elements
  578.  * 3) various properties for XSLT instructions (e.g. xsl:when,
  579.  *    xsl:with-param)
  580.  *
  581.  * REVISIT TODO: Keep this structure equal to the fields
  582.  *   defined by XSLT_ITEM_COMMON_FIELDS
  583.  */
  584. struct _xsltStylePreComp {
  585.     xsltElemPreCompPtr next;    /* next item in the global chained
  586.                    list hold by xsltStylesheet */
  587.     xsltStyleType type;         /* type of the item */ 
  588.     xsltTransformFunction func; /* handling function */
  589.     xmlNodePtr inst;        /* the node in the stylesheet's tree
  590.                    corresponding to this item. */
  591.     /* Currently no navigational fields. */
  592.     xsltNsListContainerPtr inScopeNs;
  593. };
  594.  
  595. /**
  596.  * xsltStyleBasicEmptyItem:
  597.  * 
  598.  * Abstract structure only used as a short-cut for
  599.  * XSLT items with no extra fields.
  600.  * NOTE that it is intended that this structure looks the same as
  601.  *  _xsltStylePreComp.
  602.  */
  603. typedef struct _xsltStyleBasicEmptyItem xsltStyleBasicEmptyItem;
  604. typedef xsltStyleBasicEmptyItem *xsltStyleBasicEmptyItemPtr;
  605.  
  606. struct _xsltStyleBasicEmptyItem {
  607.     XSLT_ITEM_COMMON_FIELDS
  608. };
  609.  
  610. /**
  611.  * xsltStyleBasicExpressionItem:
  612.  * 
  613.  * Abstract structure only used as a short-cut for
  614.  * XSLT items with just an expression.
  615.  */
  616. typedef struct _xsltStyleBasicExpressionItem xsltStyleBasicExpressionItem;
  617. typedef xsltStyleBasicExpressionItem *xsltStyleBasicExpressionItemPtr;
  618.  
  619. struct _xsltStyleBasicExpressionItem {
  620.     XSLT_ITEM_COMMON_FIELDS
  621.  
  622.     const xmlChar *select; /* TODO: Change this to "expression". */
  623.     xmlXPathCompExprPtr comp; /* TODO: Change this to compExpr. */
  624. };
  625.  
  626. /************************************************************************
  627.  *                                    *
  628.  * XSLT-instructions/declarations                                       *
  629.  *                                    *
  630.  ************************************************************************/
  631.  
  632. /**
  633.  * xsltStyleItemElement:
  634.  * 
  635.  * <!-- Category: instruction -->
  636.  * <xsl:element
  637.  *  name = { qname }
  638.  *  namespace = { uri-reference }
  639.  *  use-attribute-sets = qnames>
  640.  *  <!-- Content: template -->
  641.  * </xsl:element>
  642.  */
  643. typedef struct _xsltStyleItemElement xsltStyleItemElement;
  644. typedef xsltStyleItemElement *xsltStyleItemElementPtr;
  645.  
  646. struct _xsltStyleItemElement {
  647.     XSLT_ITEM_COMMON_FIELDS 
  648.  
  649.     const xmlChar *use;
  650.     int      has_use;
  651.     const xmlChar *name;    
  652.     int      has_name;
  653.     const xmlChar *ns;
  654.     const xmlChar *nsPrefix;
  655.     int      has_ns;
  656. };
  657.  
  658. /**
  659.  * xsltStyleItemAttribute:
  660.  *
  661.  * <!-- Category: instruction -->
  662.  * <xsl:attribute
  663.  *  name = { qname }
  664.  *  namespace = { uri-reference }>
  665.  *  <!-- Content: template -->
  666.  * </xsl:attribute>
  667.  */
  668. typedef struct _xsltStyleItemAttribute xsltStyleItemAttribute;
  669. typedef xsltStyleItemAttribute *xsltStyleItemAttributePtr;
  670.  
  671. struct _xsltStyleItemAttribute {
  672.     XSLT_ITEM_COMMON_FIELDS
  673.     const xmlChar *name;
  674.     int      has_name;
  675.     const xmlChar *ns;
  676.     const xmlChar *nsPrefix;
  677.     int      has_ns;
  678. };
  679.  
  680. /**
  681.  * xsltStyleItemText:
  682.  *
  683.  * <!-- Category: instruction -->
  684.  * <xsl:text
  685.  *  disable-output-escaping = "yes" | "no">
  686.  *  <!-- Content: #PCDATA -->
  687.  * </xsl:text>
  688.  */
  689. typedef struct _xsltStyleItemText xsltStyleItemText;
  690. typedef xsltStyleItemText *xsltStyleItemTextPtr;
  691.  
  692. struct _xsltStyleItemText {
  693.     XSLT_ITEM_COMMON_FIELDS
  694.     int      noescape;        /* text */
  695. };
  696.  
  697. /**
  698.  * xsltStyleItemComment:
  699.  *
  700.  * <!-- Category: instruction -->
  701.  *  <xsl:comment>
  702.  *  <!-- Content: template -->
  703.  * </xsl:comment>
  704.  */
  705. typedef xsltStyleBasicEmptyItem xsltStyleItemComment;
  706. typedef xsltStyleItemComment *xsltStyleItemCommentPtr;
  707.  
  708. /**
  709.  * xsltStyleItemPI:
  710.  *
  711.  * <!-- Category: instruction -->
  712.  *  <xsl:processing-instruction
  713.  *  name = { ncname }>
  714.  *  <!-- Content: template -->
  715.  * </xsl:processing-instruction>
  716.  */
  717. typedef struct _xsltStyleItemPI xsltStyleItemPI;
  718. typedef xsltStyleItemPI *xsltStyleItemPIPtr;
  719.  
  720. struct _xsltStyleItemPI {
  721.     XSLT_ITEM_COMMON_FIELDS
  722.     const xmlChar *name;
  723.     int      has_name;
  724. };
  725.  
  726. /**
  727.  * xsltStyleItemApplyImports:
  728.  *
  729.  * <!-- Category: instruction -->
  730.  * <xsl:apply-imports />
  731.  */
  732. typedef xsltStyleBasicEmptyItem xsltStyleItemApplyImports;
  733. typedef xsltStyleItemApplyImports *xsltStyleItemApplyImportsPtr;
  734.  
  735. /**
  736.  * xsltStyleItemApplyTemplates:
  737.  *
  738.  * <!-- Category: instruction -->
  739.  *  <xsl:apply-templates
  740.  *  select = node-set-expression
  741.  *  mode = qname>
  742.  *  <!-- Content: (xsl:sort | xsl:with-param)* -->
  743.  * </xsl:apply-templates>
  744.  */
  745. typedef struct _xsltStyleItemApplyTemplates xsltStyleItemApplyTemplates;
  746. typedef xsltStyleItemApplyTemplates *xsltStyleItemApplyTemplatesPtr;
  747.  
  748. struct _xsltStyleItemApplyTemplates {
  749.     XSLT_ITEM_COMMON_FIELDS
  750.  
  751.     const xmlChar *mode;    /* apply-templates */
  752.     const xmlChar *modeURI;    /* apply-templates */
  753.     const xmlChar *select;    /* sort, copy-of, value-of, apply-templates */
  754.     xmlXPathCompExprPtr comp;    /* a precompiled XPath expression */
  755.     /* TODO: with-params */
  756. };
  757.  
  758. /**
  759.  * xsltStyleItemCallTemplate:
  760.  *
  761.  * <!-- Category: instruction -->
  762.  *  <xsl:call-template
  763.  *  name = qname>
  764.  *  <!-- Content: xsl:with-param* -->
  765.  * </xsl:call-template>
  766.  */
  767. typedef struct _xsltStyleItemCallTemplate xsltStyleItemCallTemplate;
  768. typedef xsltStyleItemCallTemplate *xsltStyleItemCallTemplatePtr;
  769.  
  770. struct _xsltStyleItemCallTemplate {
  771.     XSLT_ITEM_COMMON_FIELDS
  772.  
  773.     xsltTemplatePtr templ;    /* call-template */
  774.     const xmlChar *name;    /* element, attribute, pi */
  775.     int      has_name;        /* element, attribute, pi */
  776.     const xmlChar *ns;        /* element */
  777.     int      has_ns;        /* element */
  778.     /* TODO: with-params */
  779. };
  780.  
  781. /**
  782.  * xsltStyleItemCopy:
  783.  *
  784.  * <!-- Category: instruction -->
  785.  * <xsl:copy
  786.  *  use-attribute-sets = qnames>
  787.  *  <!-- Content: template -->
  788.  * </xsl:copy>
  789.  */
  790. typedef struct _xsltStyleItemCopy xsltStyleItemCopy;
  791. typedef xsltStyleItemCopy *xsltStyleItemCopyPtr;
  792.  
  793. struct _xsltStyleItemCopy {
  794.    XSLT_ITEM_COMMON_FIELDS
  795.     const xmlChar *use;        /* copy, element */
  796.     int      has_use;        /* copy, element */    
  797. };
  798.  
  799. /**
  800.  * xsltStyleItemIf:
  801.  *
  802.  * <!-- Category: instruction -->
  803.  *  <xsl:if
  804.  *  test = boolean-expression>
  805.  *  <!-- Content: template -->
  806.  * </xsl:if>
  807.  */
  808. typedef struct _xsltStyleItemIf xsltStyleItemIf;
  809. typedef xsltStyleItemIf *xsltStyleItemIfPtr;
  810.  
  811. struct _xsltStyleItemIf {
  812.     XSLT_ITEM_COMMON_FIELDS
  813.  
  814.     const xmlChar *test;    /* if */
  815.     xmlXPathCompExprPtr comp;    /* a precompiled XPath expression */
  816. };
  817.  
  818.  
  819. /**
  820.  * xsltStyleItemCopyOf:
  821.  *
  822.  * <!-- Category: instruction -->
  823.  * <xsl:copy-of
  824.  *  select = expression />
  825.  */
  826. typedef xsltStyleBasicExpressionItem xsltStyleItemCopyOf;
  827. typedef xsltStyleItemCopyOf *xsltStyleItemCopyOfPtr;
  828.  
  829. /**
  830.  * xsltStyleItemValueOf:
  831.  *
  832.  * <!-- Category: instruction -->
  833.  * <xsl:value-of
  834.  *  select = string-expression
  835.  *  disable-output-escaping = "yes" | "no" />
  836.  */
  837. typedef struct _xsltStyleItemValueOf xsltStyleItemValueOf;
  838. typedef xsltStyleItemValueOf *xsltStyleItemValueOfPtr;
  839.  
  840. struct _xsltStyleItemValueOf {
  841.     XSLT_ITEM_COMMON_FIELDS
  842.  
  843.     const xmlChar *select;
  844.     xmlXPathCompExprPtr comp;    /* a precompiled XPath expression */
  845.     int      noescape;
  846. };
  847.  
  848. /**
  849.  * xsltStyleItemNumber:
  850.  *
  851.  * <!-- Category: instruction -->
  852.  *  <xsl:number
  853.  *  level = "single" | "multiple" | "any"
  854.  *  count = pattern
  855.  *  from = pattern
  856.  *  value = number-expression
  857.  *  format = { string }
  858.  *  lang = { nmtoken }
  859.  *  letter-value = { "alphabetic" | "traditional" }
  860.  *  grouping-separator = { char }
  861.  *  grouping-size = { number } />
  862.  */
  863. typedef struct _xsltStyleItemNumber xsltStyleItemNumber;
  864. typedef xsltStyleItemNumber *xsltStyleItemNumberPtr;
  865.  
  866. struct _xsltStyleItemNumber {
  867.     XSLT_ITEM_COMMON_FIELDS
  868.     xsltNumberData numdata;    /* number */
  869. };
  870.  
  871. /**
  872.  * xsltStyleItemChoose:
  873.  *
  874.  * <!-- Category: instruction -->
  875.  *  <xsl:choose>
  876.  *  <!-- Content: (xsl:when+, xsl:otherwise?) -->
  877.  * </xsl:choose>
  878.  */
  879. typedef xsltStyleBasicEmptyItem xsltStyleItemChoose;
  880. typedef xsltStyleItemChoose *xsltStyleItemChoosePtr;
  881.  
  882. /**
  883.  * xsltStyleItemFallback:
  884.  *
  885.  * <!-- Category: instruction -->
  886.  *  <xsl:fallback>
  887.  *  <!-- Content: template -->
  888.  * </xsl:fallback>
  889.  */
  890. typedef xsltStyleBasicEmptyItem xsltStyleItemFallback;
  891. typedef xsltStyleItemFallback *xsltStyleItemFallbackPtr;
  892.  
  893. /**
  894.  * xsltStyleItemForEach:
  895.  *
  896.  * <!-- Category: instruction -->
  897.  * <xsl:for-each
  898.  *   select = node-set-expression>
  899.  *   <!-- Content: (xsl:sort*, template) -->
  900.  * </xsl:for-each>
  901.  */
  902. typedef xsltStyleBasicExpressionItem xsltStyleItemForEach;
  903. typedef xsltStyleItemForEach *xsltStyleItemForEachPtr;
  904.  
  905. /**
  906.  * xsltStyleItemMessage:
  907.  *
  908.  * <!-- Category: instruction -->
  909.  * <xsl:message
  910.  *   terminate = "yes" | "no">
  911.  *   <!-- Content: template -->
  912.  * </xsl:message>
  913.  */
  914. typedef struct _xsltStyleItemMessage xsltStyleItemMessage;
  915. typedef xsltStyleItemMessage *xsltStyleItemMessagePtr;
  916.  
  917. struct _xsltStyleItemMessage {
  918.     XSLT_ITEM_COMMON_FIELDS    
  919.     int terminate;
  920. };
  921.  
  922. /**
  923.  * xsltStyleItemDocument:
  924.  *
  925.  * NOTE: This is not an instruction of XSLT 1.0.
  926.  */
  927. typedef struct _xsltStyleItemDocument xsltStyleItemDocument;
  928. typedef xsltStyleItemDocument *xsltStyleItemDocumentPtr;
  929.  
  930. struct _xsltStyleItemDocument {
  931.     XSLT_ITEM_COMMON_FIELDS
  932.     int      ver11;        /* assigned: in xsltDocumentComp;
  933.                                   read: nowhere;
  934.                                   TODO: Check if we need. */
  935.     const xmlChar *filename;    /* document URL */
  936.     int has_filename;
  937. };   
  938.  
  939. /************************************************************************
  940.  *                                    *
  941.  * Non-instructions (actually properties of instructions/declarations)  *
  942.  *                                    *
  943.  ************************************************************************/
  944.  
  945. /**
  946.  * xsltStyleBasicItemVariable:
  947.  *
  948.  * Basic struct for xsl:variable, xsl:param and xsl:with-param.
  949.  * It's currently important to have equal fields, since
  950.  * xsltParseStylesheetCallerParam() is used with xsl:with-param from
  951.  * the xslt side and with xsl:param from the exslt side (in
  952.  * exsltFuncFunctionFunction()).
  953.  *
  954.  * FUTURE NOTE: In XSLT 2.0 xsl:param, xsl:variable and xsl:with-param
  955.  *   have additional different fields.
  956.  */
  957. typedef struct _xsltStyleBasicItemVariable xsltStyleBasicItemVariable;
  958. typedef xsltStyleBasicItemVariable *xsltStyleBasicItemVariablePtr;
  959.  
  960. struct _xsltStyleBasicItemVariable {
  961.     XSLT_ITEM_COMMON_FIELDS
  962.  
  963.     const xmlChar *select;
  964.     xmlXPathCompExprPtr comp;
  965.  
  966.     const xmlChar *name;
  967.     int      has_name;
  968.     const xmlChar *ns;
  969.     int      has_ns;
  970. };
  971.  
  972. /**
  973.  * xsltStyleItemVariable:
  974.  *
  975.  * <!-- Category: top-level-element -->
  976.  * <xsl:param
  977.  *   name = qname
  978.  *   select = expression>
  979.  *   <!-- Content: template -->
  980.  * </xsl:param>
  981.  */
  982. typedef xsltStyleBasicItemVariable xsltStyleItemVariable;
  983. typedef xsltStyleItemVariable *xsltStyleItemVariablePtr;
  984.  
  985. /**
  986.  * xsltStyleItemParam:
  987.  *
  988.  * <!-- Category: top-level-element -->
  989.  * <xsl:param
  990.  *   name = qname
  991.  *   select = expression>
  992.  *   <!-- Content: template -->
  993.  * </xsl:param>
  994.  */
  995. typedef struct _xsltStyleItemParam xsltStyleItemParam;
  996. typedef xsltStyleItemParam *xsltStyleItemParamPtr;
  997.  
  998. struct _xsltStyleItemParam {
  999.     XSLT_ITEM_COMMON_FIELDS
  1000.  
  1001.     const xmlChar *select;
  1002.     xmlXPathCompExprPtr comp;
  1003.  
  1004.     const xmlChar *name;
  1005.     int      has_name;
  1006.     const xmlChar *ns;
  1007.     int      has_ns;    
  1008. };
  1009.  
  1010. /**
  1011.  * xsltStyleItemWithParam:
  1012.  *
  1013.  * <xsl:with-param
  1014.  *  name = qname
  1015.  *  select = expression>
  1016.  *  <!-- Content: template -->
  1017.  * </xsl:with-param>
  1018.  */
  1019. typedef xsltStyleBasicItemVariable xsltStyleItemWithParam;
  1020. typedef xsltStyleItemWithParam *xsltStyleItemWithParamPtr;
  1021.  
  1022. /**
  1023.  * xsltStyleItemSort:
  1024.  *
  1025.  * Reflects the XSLT xsl:sort item.
  1026.  * Allowed parents: xsl:apply-templates, xsl:for-each
  1027.  * <xsl:sort
  1028.  *   select = string-expression
  1029.  *   lang = { nmtoken }
  1030.  *   data-type = { "text" | "number" | qname-but-not-ncname }
  1031.  *   order = { "ascending" | "descending" }
  1032.  *   case-order = { "upper-first" | "lower-first" } />
  1033.  */
  1034. typedef struct _xsltStyleItemSort xsltStyleItemSort;
  1035. typedef xsltStyleItemSort *xsltStyleItemSortPtr;
  1036.  
  1037. struct _xsltStyleItemSort {
  1038.     XSLT_ITEM_COMMON_FIELDS
  1039.  
  1040.     const xmlChar *stype;       /* sort */
  1041.     int      has_stype;        /* sort */
  1042.     int      number;        /* sort */
  1043.     const xmlChar *order;    /* sort */
  1044.     int      has_order;        /* sort */
  1045.     int      descending;    /* sort */
  1046.     const xmlChar *lang;    /* sort */
  1047.     int      has_lang;        /* sort */
  1048.     const xmlChar *case_order;    /* sort */
  1049.     int      lower_first;    /* sort */
  1050.  
  1051.     const xmlChar *use;
  1052.     int      has_use;
  1053.  
  1054.     const xmlChar *select;    /* sort, copy-of, value-of, apply-templates */
  1055.  
  1056.     xmlXPathCompExprPtr comp;    /* a precompiled XPath expression */
  1057. };
  1058.  
  1059.  
  1060. /**
  1061.  * xsltStyleItemWhen:
  1062.  * 
  1063.  * <xsl:when
  1064.  *   test = boolean-expression>
  1065.  *   <!-- Content: template -->
  1066.  * </xsl:when>
  1067.  * Allowed parent: xsl:choose
  1068.  */
  1069. typedef struct _xsltStyleItemWhen xsltStyleItemWhen;
  1070. typedef xsltStyleItemWhen *xsltStyleItemWhenPtr;
  1071.  
  1072. struct _xsltStyleItemWhen {
  1073.     XSLT_ITEM_COMMON_FIELDS
  1074.  
  1075.     const xmlChar *test;
  1076.     xmlXPathCompExprPtr comp;
  1077. };
  1078.  
  1079. /**
  1080.  * xsltStyleItemOtherwise:
  1081.  *
  1082.  * Allowed parent: xsl:choose
  1083.  * <xsl:otherwise>
  1084.  *   <!-- Content: template -->
  1085.  * </xsl:otherwise>
  1086.  */
  1087. typedef struct _xsltStyleItemOtherwise xsltStyleItemOtherwise;
  1088. typedef xsltStyleItemOtherwise *xsltStyleItemOtherwisePtr;
  1089.  
  1090. struct _xsltStyleItemOtherwise {
  1091.     XSLT_ITEM_COMMON_FIELDS
  1092. };
  1093.  
  1094. typedef struct _xsltStyleItemInclude xsltStyleItemInclude;
  1095. typedef xsltStyleItemInclude *xsltStyleItemIncludePtr;
  1096.  
  1097. struct _xsltStyleItemInclude {
  1098.     XSLT_ITEM_COMMON_FIELDS
  1099.     xsltDocumentPtr include;
  1100. };
  1101.  
  1102. /************************************************************************
  1103.  *                                    *
  1104.  *  XSLT elements in forwards-compatible mode                           *
  1105.  *                                    *
  1106.  ************************************************************************/
  1107.  
  1108. typedef struct _xsltStyleItemUknown xsltStyleItemUknown;
  1109. typedef xsltStyleItemUknown *xsltStyleItemUknownPtr;
  1110. struct _xsltStyleItemUknown {
  1111.     XSLT_ITEM_COMMON_FIELDS
  1112. };
  1113.  
  1114.  
  1115. /************************************************************************
  1116.  *                                    *
  1117.  *  Extension elements                                                  *
  1118.  *                                    *
  1119.  ************************************************************************/
  1120.  
  1121. /*
  1122.  * xsltStyleItemExtElement:
  1123.  *
  1124.  * Reflects extension elements.
  1125.  *
  1126.  * NOTE: Due to the fact that the structure xsltElemPreComp is most
  1127.  * probably already heavily in use out there by users, so we cannot
  1128.  * easily change it, we'll create an intermediate structure which will
  1129.  * hold an xsltElemPreCompPtr.
  1130.  * BIG NOTE: The only problem I see here is that the user processes the
  1131.  *  content of the stylesheet tree, possibly he'll lookup the node->psvi
  1132.  *  fields in order to find subsequent extension functions.
  1133.  *  In this case, the user's code will break, since the node->psvi
  1134.  *  field will hold now the xsltStyleItemExtElementPtr and not
  1135.  *  the xsltElemPreCompPtr.
  1136.  *  However the place where the structure is anchored in the node-tree,
  1137.  *  namely node->psvi, has beed already once been moved from node->_private
  1138.  *  to node->psvi, so we have a precedent here, which, I think, should allow
  1139.  *  us to change such semantics without headaches.
  1140.  */
  1141. typedef struct _xsltStyleItemExtElement xsltStyleItemExtElement;
  1142. typedef xsltStyleItemExtElement *xsltStyleItemExtElementPtr;
  1143. struct _xsltStyleItemExtElement {
  1144.     XSLT_ITEM_COMMON_FIELDS
  1145.     xsltElemPreCompPtr item;   
  1146. };
  1147.  
  1148. /************************************************************************
  1149.  *                                    *
  1150.  *  Literal result elements                                             *
  1151.  *                                    *
  1152.  ************************************************************************/
  1153.  
  1154. typedef struct _xsltEffectiveNs xsltEffectiveNs;
  1155. typedef xsltEffectiveNs *xsltEffectiveNsPtr;
  1156. struct _xsltEffectiveNs {
  1157.     xsltEffectiveNsPtr nextInStore; /* storage next */
  1158.     xsltEffectiveNsPtr next; /* next item in the list */
  1159.     const xmlChar *prefix;
  1160.     const xmlChar *nsName;
  1161.     /* 
  1162.     * Indicates if eclared on the literal result element; dunno if really
  1163.     * needed.
  1164.     */
  1165.     int holdByElem;
  1166. };
  1167.  
  1168. /*
  1169.  * Info for literal result elements.
  1170.  * This will be set on the elem->psvi field and will be
  1171.  * shared by literal result elements, which have the same
  1172.  * excluded result namespaces; i.e., this *won't* be created uniquely
  1173.  * for every literal result element.
  1174.  */
  1175. typedef struct _xsltStyleItemLRElementInfo xsltStyleItemLRElementInfo;
  1176. typedef xsltStyleItemLRElementInfo *xsltStyleItemLRElementInfoPtr;
  1177. struct _xsltStyleItemLRElementInfo {
  1178.     XSLT_ITEM_COMMON_FIELDS
  1179.     /*
  1180.     * @effectiveNs is the set of effective ns-nodes
  1181.     *  on the literal result element, which will be added to the result
  1182.     *  element if not already existing in the result tree.
  1183.     *  This means that excluded namespaces (via exclude-result-prefixes,
  1184.     *  extension-element-prefixes and the XSLT namespace) not added
  1185.     *  to the set.
  1186.     *  Namespace-aliasing was applied on the @effectiveNs.
  1187.     */
  1188.     xsltEffectiveNsPtr effectiveNs;
  1189.  
  1190. };
  1191.  
  1192. #ifdef XSLT_REFACTORED
  1193.  
  1194. typedef struct _xsltNsAlias xsltNsAlias;
  1195. typedef xsltNsAlias *xsltNsAliasPtr;
  1196. struct _xsltNsAlias {
  1197.     xsltNsAliasPtr next; /* next in the list */    
  1198.     xmlNsPtr literalNs;
  1199.     xmlNsPtr targetNs;
  1200.     xmlDocPtr docOfTargetNs;
  1201. };
  1202. #endif
  1203.  
  1204. #ifdef XSLT_REFACTORED_XSLT_NSCOMP
  1205.  
  1206. typedef struct _xsltNsMap xsltNsMap;
  1207. typedef xsltNsMap *xsltNsMapPtr;
  1208. struct _xsltNsMap {
  1209.     xsltNsMapPtr next; /* next in the list */
  1210.     xmlDocPtr doc;
  1211.     xmlNodePtr elem; /* the element holding the ns-decl */
  1212.     xmlNsPtr ns; /* the xmlNs structure holding the XML namespace name */
  1213.     const xmlChar *origNsName; /* the original XML namespace name */
  1214.     const xmlChar *newNsName; /* the mapped XML namespace name */    
  1215. };
  1216. #endif
  1217.  
  1218. /************************************************************************
  1219.  *                                    *
  1220.  *  Compile-time structures for *internal* use only                     *
  1221.  *                                    *
  1222.  ************************************************************************/
  1223.  
  1224. typedef struct _xsltPrincipalStylesheetData xsltPrincipalStylesheetData;
  1225. typedef xsltPrincipalStylesheetData *xsltPrincipalStylesheetDataPtr;
  1226.  
  1227. typedef struct _xsltNsList xsltNsList;
  1228. typedef xsltNsList *xsltNsListPtr;
  1229. struct _xsltNsList {
  1230.     xsltNsListPtr next; /* next in the list */
  1231.     xmlNsPtr ns;
  1232. };
  1233.  
  1234. /*
  1235. * xsltVarInfo:
  1236. *
  1237. * Used at compilation time for parameters and variables.
  1238. */
  1239. typedef struct _xsltVarInfo xsltVarInfo;
  1240. typedef xsltVarInfo *xsltVarInfoPtr;
  1241. struct _xsltVarInfo {
  1242.     xsltVarInfoPtr next; /* next in the list */
  1243.     xsltVarInfoPtr prev;
  1244.     int depth; /* the depth in the tree */
  1245.     const xmlChar *name;
  1246.     const xmlChar *nsName;
  1247. };
  1248.  
  1249. #define XSLT_ELEMENT_CATEGORY_XSLT 0
  1250. #define XSLT_ELEMENT_CATEGORY_EXTENSION 1
  1251. #define XSLT_ELEMENT_CATEGORY_LRE 2
  1252.  
  1253. /**
  1254.  * xsltCompilerNodeInfo:
  1255.  *
  1256.  * Per-node information during compile-time.
  1257.  */
  1258. typedef struct _xsltCompilerNodeInfo xsltCompilerNodeInfo;
  1259. typedef xsltCompilerNodeInfo *xsltCompilerNodeInfoPtr;
  1260. struct _xsltCompilerNodeInfo {
  1261.     xsltCompilerNodeInfoPtr next;
  1262.     xsltCompilerNodeInfoPtr prev;
  1263.     xmlNodePtr node;
  1264.     int depth;
  1265.     xsltTemplatePtr templ;   /* The owning template */
  1266.     int category;         /* XSLT element, LR-element or
  1267.                                 extension element */
  1268.     xsltStyleType type;
  1269.     xsltElemPreCompPtr item; /* The compiled information */
  1270.     /* The current in-scope namespaces */
  1271.     xsltNsListContainerPtr inScopeNs;
  1272.     /* The current excluded result namespaces */
  1273.     xsltPointerListPtr exclResultNs; 
  1274.     /* The current extension instruction namespaces */
  1275.     xsltPointerListPtr extElemNs;
  1276.  
  1277.     /* The current info for literal result elements. */
  1278.     xsltStyleItemLRElementInfoPtr litResElemInfo;
  1279.     /* 
  1280.     * Set to 1 if in-scope namespaces changed,
  1281.     *  or excluded result namespaces changed,
  1282.     *  or extension element namespaces changed.
  1283.     * This will trigger creation of new infos
  1284.     *  for literal result elements.
  1285.     */
  1286.     int nsChanged;
  1287.     int preserveWhitespace;
  1288.     int stripWhitespace;
  1289.     int isRoot; /* whether this is the stylesheet's root node */
  1290.     int forwardsCompat; /* whether forwards-compatible mode is enabled */
  1291.     /* whether the content of an extension element was processed */
  1292.     int extContentHandled;
  1293.     /* the type of the current child */
  1294.     xsltStyleType curChildType;    
  1295. };
  1296.  
  1297. /**
  1298.  * XSLT_CCTXT:
  1299.  *
  1300.  * get pointer to compiler context
  1301.  */
  1302. #define XSLT_CCTXT(style) ((xsltCompilerCtxtPtr) style->compCtxt) 
  1303.  
  1304. typedef enum {
  1305.     XSLT_ERROR_SEVERITY_ERROR = 0,
  1306.     XSLT_ERROR_SEVERITY_WARNING
  1307. } xsltErrorSeverityType;
  1308.  
  1309. typedef struct _xsltCompilerCtxt xsltCompilerCtxt;
  1310. typedef xsltCompilerCtxt *xsltCompilerCtxtPtr;
  1311. struct _xsltCompilerCtxt {
  1312.     void *errorCtxt;            /* user specific error context */
  1313.     /*
  1314.     * used for error/warning reports; e.g. XSLT_ERROR_SEVERITY_WARNING */
  1315.     xsltErrorSeverityType errSeverity;        
  1316.     int warnings;        /* TODO: number of warnings found at
  1317.                                    compilation */
  1318.     int errors;            /* TODO: number of errors found at
  1319.                                    compilation */
  1320.     xmlDictPtr dict;
  1321.     xsltStylesheetPtr style;
  1322.     int simplified; /* whether this is a simplified stylesheet */
  1323.     /* TODO: structured/unstructured error contexts. */
  1324.     int depth; /* Current depth of processing */
  1325.     
  1326.     xsltCompilerNodeInfoPtr inode;
  1327.     xsltCompilerNodeInfoPtr inodeList;
  1328.     xsltCompilerNodeInfoPtr inodeLast;
  1329.     xsltPointerListPtr tmpList; /* Used for various purposes */
  1330.     /*
  1331.     * The XSLT version as specified by the stylesheet's root element.
  1332.     */
  1333.     int isInclude;
  1334.     int hasForwardsCompat; /* whether forwards-compatible mode was used
  1335.                  in a parsing episode */
  1336.     int maxNodeInfos; /* TEMP TODO: just for the interest */
  1337.     int maxLREs;  /* TEMP TODO: just for the interest */
  1338.     /* 
  1339.     * In order to keep the old behaviour, applying strict rules of
  1340.     * the spec can be turned off. This has effect only on special
  1341.     * mechanisms like whitespace-stripping in the stylesheet.
  1342.     */
  1343.     int strict;
  1344.     xsltPrincipalStylesheetDataPtr psData;
  1345. #ifdef XSLT_REFACTORED_XPATHCOMP
  1346.     xmlXPathContextPtr xpathCtxt;
  1347. #endif
  1348.     xsltStyleItemUknownPtr unknownItem;
  1349.     int hasNsAliases; /* Indicator if there was an xsl:namespace-alias. */
  1350.     xsltNsAliasPtr nsAliases;
  1351.     xsltVarInfoPtr ivars; /* Storage of local in-scope variables/params. */
  1352.     xsltVarInfoPtr ivar; /* topmost local variable/param. */
  1353. };   
  1354.  
  1355. #else /* XSLT_REFACTORED */
  1356. /*
  1357. * The old structures before refactoring.
  1358. */
  1359.  
  1360. /**
  1361.  * _xsltStylePreComp:
  1362.  *
  1363.  * The in-memory structure corresponding to XSLT stylesheet constructs
  1364.  * precomputed data.
  1365.  */
  1366. struct _xsltStylePreComp {
  1367.     xsltElemPreCompPtr next;    /* chained list */
  1368.     xsltStyleType type;        /* type of the element */
  1369.     xsltTransformFunction func; /* handling function */
  1370.     xmlNodePtr inst;        /* the instruction */
  1371.  
  1372.     /*
  1373.      * Pre computed values.
  1374.      */
  1375.  
  1376.     const xmlChar *stype;       /* sort */
  1377.     int      has_stype;        /* sort */
  1378.     int      number;        /* sort */
  1379.     const xmlChar *order;    /* sort */
  1380.     int      has_order;        /* sort */
  1381.     int      descending;    /* sort */
  1382.     const xmlChar *lang;    /* sort */
  1383.     int      has_lang;        /* sort */
  1384.     const xmlChar *case_order;    /* sort */
  1385.     int      lower_first;    /* sort */
  1386.  
  1387.     const xmlChar *use;        /* copy, element */
  1388.     int      has_use;        /* copy, element */
  1389.  
  1390.     int      noescape;        /* text */
  1391.  
  1392.     const xmlChar *name;    /* element, attribute, pi */
  1393.     int      has_name;        /* element, attribute, pi */
  1394.     const xmlChar *ns;        /* element */
  1395.     int      has_ns;        /* element */
  1396.  
  1397.     const xmlChar *mode;    /* apply-templates */
  1398.     const xmlChar *modeURI;    /* apply-templates */
  1399.  
  1400.     const xmlChar *test;    /* if */
  1401.  
  1402.     xsltTemplatePtr templ;    /* call-template */
  1403.  
  1404.     const xmlChar *select;    /* sort, copy-of, value-of, apply-templates */
  1405.  
  1406.     int      ver11;        /* document */
  1407.     const xmlChar *filename;    /* document URL */
  1408.     int      has_filename;    /* document */
  1409.  
  1410.     xsltNumberData numdata;    /* number */
  1411.  
  1412.     xmlXPathCompExprPtr comp;    /* a precompiled XPath expression */
  1413.     xmlNsPtr *nsList;        /* the namespaces in scope */
  1414.     int nsNr;            /* the number of namespaces in scope */
  1415. };
  1416.  
  1417. #endif /* XSLT_REFACTORED */
  1418.  
  1419.  
  1420. #define XSLT_VAR_GLOBAL 1<<0
  1421. #define XSLT_VAR_IN_SELECT 1<<1
  1422. #define XSLT_TCTXT_VARIABLE(c) ((xsltStackElemPtr) (c)->contextVariable)
  1423. /*
  1424.  * The in-memory structure corresponding to an XSLT Variable
  1425.  * or Param.
  1426.  */
  1427. typedef struct _xsltStackElem xsltStackElem;
  1428. typedef xsltStackElem *xsltStackElemPtr;
  1429. struct _xsltStackElem {
  1430.     struct _xsltStackElem *next;/* chained list */
  1431.     xsltStylePreCompPtr comp;   /* the compiled form */
  1432.     int computed;        /* was the evaluation done */
  1433.     const xmlChar *name;    /* the local part of the name QName */
  1434.     const xmlChar *nameURI;    /* the URI part of the name QName */
  1435.     const xmlChar *select;    /* the eval string */
  1436.     xmlNodePtr tree;        /* the sequence constructor if no eval
  1437.                     string or the location */
  1438.     xmlXPathObjectPtr value;    /* The value if computed */
  1439.     xmlDocPtr fragment;        /* The Result Tree Fragments (needed for XSLT 1.0)
  1440.                    which are bound to the variable's lifetime. */
  1441.     int level;                  /* the depth in the tree;
  1442.                                    -1 if persistent (e.g. a given xsl:with-param) */
  1443.     xsltTransformContextPtr context; /* The transformation context; needed to cache
  1444.                                         the variables */
  1445.     int flags;
  1446. };
  1447.  
  1448. #ifdef XSLT_REFACTORED
  1449.  
  1450. struct _xsltPrincipalStylesheetData {
  1451.     /*
  1452.     * Namespace dictionary for ns-prefixes and ns-names:
  1453.     * TODO: Shared between stylesheets, and XPath mechanisms.
  1454.     *   Not used yet.
  1455.     */
  1456.     xmlDictPtr namespaceDict;
  1457.     /*
  1458.     * Global list of in-scope namespaces.
  1459.     */
  1460.     xsltPointerListPtr inScopeNamespaces;
  1461.     /*
  1462.     * Global list of information for [xsl:]excluded-result-prefixes.
  1463.     */
  1464.     xsltPointerListPtr exclResultNamespaces;
  1465.     /*
  1466.     * Global list of information for [xsl:]extension-element-prefixes.
  1467.     */
  1468.     xsltPointerListPtr extElemNamespaces;
  1469.     xsltEffectiveNsPtr effectiveNs;
  1470. #ifdef XSLT_REFACTORED_XSLT_NSCOMP
  1471.     /*
  1472.     * Namespace name map to get rid of string comparison of namespace names.
  1473.     */
  1474.     xsltNsMapPtr nsMap;
  1475. #endif
  1476. };
  1477.  
  1478.     
  1479. #endif
  1480. /*
  1481.  * Note that we added a @compCtxt field to anchor an stylesheet compilation
  1482.  * context, since, due to historical reasons, various compile-time function
  1483.  * take only the stylesheet as argument and not a compilation context.
  1484.  */
  1485. struct _xsltStylesheet {
  1486.     /*
  1487.      * The stylesheet import relation is kept as a tree.
  1488.      */
  1489.     struct _xsltStylesheet *parent;
  1490.     struct _xsltStylesheet *next;
  1491.     struct _xsltStylesheet *imports;
  1492.  
  1493.     xsltDocumentPtr docList;        /* the include document list */
  1494.  
  1495.     /*
  1496.      * General data on the style sheet document.
  1497.      */
  1498.     xmlDocPtr doc;        /* the parsed XML stylesheet */
  1499.     xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and
  1500.                    preserve space elements */
  1501.     int             stripAll;    /* strip-space * (1) preserve-space * (-1) */
  1502.     xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */
  1503.  
  1504.     /*
  1505.      * Global variable or parameters.
  1506.      */
  1507.     xsltStackElemPtr variables; /* linked list of param and variables */
  1508.  
  1509.     /*
  1510.      * Template descriptions.
  1511.      */
  1512.     xsltTemplatePtr templates;    /* the ordered list of templates */
  1513.     void *templatesHash;    /* hash table or wherever compiled templates
  1514.                    informations are stored */
  1515.     void *rootMatch;        /* template based on / */
  1516.     void *keyMatch;        /* template based on key() */
  1517.     void *elemMatch;        /* template based on * */
  1518.     void *attrMatch;        /* template based on @* */
  1519.     void *parentMatch;        /* template based on .. */
  1520.     void *textMatch;        /* template based on text() */
  1521.     void *piMatch;        /* template based on processing-instruction() */
  1522.     void *commentMatch;        /* template based on comment() */
  1523.     
  1524.     /*
  1525.      * Namespace aliases.
  1526.      * NOTE: Not used in the refactored code.
  1527.      */
  1528.     xmlHashTablePtr nsAliases;    /* the namespace alias hash tables */
  1529.  
  1530.     /*
  1531.      * Attribute sets.
  1532.      */
  1533.     xmlHashTablePtr attributeSets;/* the attribute sets hash tables */
  1534.  
  1535.     /*
  1536.      * Namespaces.
  1537.      * TODO: Eliminate this.
  1538.      */
  1539.     xmlHashTablePtr nsHash;     /* the set of namespaces in use:
  1540.                                    ATTENTION: This is used for
  1541.                                    execution of XPath expressions; unfortunately
  1542.                                    it restricts the stylesheet to have distinct
  1543.                                    prefixes.
  1544.                    TODO: We need to get rid of this.    
  1545.                  */
  1546.     void           *nsDefs;     /* ATTENTION TODO: This is currently used to store
  1547.                    xsltExtDefPtr (in extensions.c) and
  1548.                                    *not* xmlNsPtr.
  1549.                  */
  1550.  
  1551.     /*
  1552.      * Key definitions.
  1553.      */
  1554.     void *keys;            /* key definitions */
  1555.  
  1556.     /*
  1557.      * Output related stuff.
  1558.      */
  1559.     xmlChar *method;        /* the output method */
  1560.     xmlChar *methodURI;        /* associated namespace if any */
  1561.     xmlChar *version;        /* version string */
  1562.     xmlChar *encoding;        /* encoding string */
  1563.     int omitXmlDeclaration;     /* omit-xml-declaration = "yes" | "no" */
  1564.  
  1565.     /* 
  1566.      * Number formatting.
  1567.      */
  1568.     xsltDecimalFormatPtr decimalFormat;
  1569.     int standalone;             /* standalone = "yes" | "no" */
  1570.     xmlChar *doctypePublic;     /* doctype-public string */
  1571.     xmlChar *doctypeSystem;     /* doctype-system string */
  1572.     int indent;            /* should output being indented */
  1573.     xmlChar *mediaType;        /* media-type string */
  1574.  
  1575.     /*
  1576.      * Precomputed blocks.
  1577.      */
  1578.     xsltElemPreCompPtr preComps;/* list of precomputed blocks */
  1579.     int warnings;        /* number of warnings found at compilation */
  1580.     int errors;            /* number of errors found at compilation */
  1581.  
  1582.     xmlChar  *exclPrefix;    /* last excluded prefixes */
  1583.     xmlChar **exclPrefixTab;    /* array of excluded prefixes */
  1584.     int       exclPrefixNr;    /* number of excluded prefixes in scope */
  1585.     int       exclPrefixMax;    /* size of the array */
  1586.  
  1587.     void     *_private;        /* user defined data */
  1588.  
  1589.     /*
  1590.      * Extensions.
  1591.      */
  1592.     xmlHashTablePtr extInfos;    /* the extension data */
  1593.     int            extrasNr;    /* the number of extras required */
  1594.  
  1595.     /*
  1596.      * For keeping track of nested includes
  1597.      */
  1598.     xsltDocumentPtr includes;    /* points to last nested include */
  1599.  
  1600.     /*
  1601.      * dictionary: shared between stylesheet, context and documents.
  1602.      */
  1603.     xmlDictPtr dict;
  1604.     /*
  1605.      * precompiled attribute value templates.
  1606.      */
  1607.     void *attVTs;
  1608.     /*
  1609.      * if namespace-alias has an alias for the default stylesheet prefix
  1610.      * NOTE: Not used in the refactored code.
  1611.      */
  1612.     const xmlChar *defaultAlias;
  1613.     /*
  1614.      * bypass pre-processing (already done) (used in imports)
  1615.      */
  1616.     int nopreproc;
  1617.     /*
  1618.      * all document text strings were internalized
  1619.      */
  1620.     int internalized;
  1621.     /*
  1622.      * Literal Result Element as Stylesheet c.f. section 2.3
  1623.      */
  1624.     int literal_result;
  1625.     /*
  1626.     * The principal stylesheet
  1627.     */
  1628.     xsltStylesheetPtr principal;
  1629. #ifdef XSLT_REFACTORED
  1630.     /*
  1631.     * Compilation context used during compile-time.
  1632.     */
  1633.     xsltCompilerCtxtPtr compCtxt; /* TODO: Change this to (void *). */
  1634.  
  1635.     xsltPrincipalStylesheetDataPtr principalData;    
  1636. #endif
  1637. };
  1638.  
  1639. typedef struct _xsltTransformCache xsltTransformCache;
  1640. typedef xsltTransformCache *xsltTransformCachePtr;
  1641. struct _xsltTransformCache {
  1642.     xmlDocPtr RVT;
  1643.     int nbRVT;
  1644.     xsltStackElemPtr stackItems;
  1645.     int nbStackItems;
  1646. #ifdef XSLT_DEBUG_PROFILE_CACHE
  1647.     int dbgCachedRVTs;
  1648.     int dbgReusedRVTs;
  1649.     int dbgCachedVars;
  1650.     int dbgReusedVars;
  1651. #endif
  1652. };
  1653.  
  1654. /*
  1655.  * The in-memory structure corresponding to an XSLT Transformation.
  1656.  */
  1657. typedef enum {
  1658.     XSLT_OUTPUT_XML = 0,
  1659.     XSLT_OUTPUT_HTML,
  1660.     XSLT_OUTPUT_TEXT
  1661. } xsltOutputType;
  1662.  
  1663. typedef enum {
  1664.     XSLT_STATE_OK = 0,
  1665.     XSLT_STATE_ERROR,
  1666.     XSLT_STATE_STOPPED
  1667. } xsltTransformState;
  1668.  
  1669. struct _xsltTransformContext {
  1670.     xsltStylesheetPtr style;        /* the stylesheet used */
  1671.     xsltOutputType type;        /* the type of output */
  1672.  
  1673.     xsltTemplatePtr  templ;        /* the current template */
  1674.     int              templNr;        /* Nb of templates in the stack */
  1675.     int              templMax;        /* Size of the templtes stack */
  1676.     xsltTemplatePtr *templTab;        /* the template stack */
  1677.  
  1678.     xsltStackElemPtr  vars;        /* the current variable list */
  1679.     int               varsNr;        /* Nb of variable list in the stack */
  1680.     int               varsMax;        /* Size of the variable list stack */
  1681.     xsltStackElemPtr *varsTab;        /* the variable list stack */
  1682.     int               varsBase;        /* the var base for current templ */
  1683.  
  1684.     /*
  1685.      * Extensions
  1686.      */
  1687.     xmlHashTablePtr   extFunctions;    /* the extension functions */
  1688.     xmlHashTablePtr   extElements;    /* the extension elements */
  1689.     xmlHashTablePtr   extInfos;        /* the extension data */
  1690.  
  1691.     const xmlChar *mode;        /* the current mode */
  1692.     const xmlChar *modeURI;        /* the current mode URI */
  1693.  
  1694.     xsltDocumentPtr docList;        /* the document list */
  1695.  
  1696.     xsltDocumentPtr document;        /* the current source document; can be NULL if an RTF */
  1697.     xmlNodePtr node;            /* the current node being processed */
  1698.     xmlNodeSetPtr nodeList;        /* the current node list */
  1699.     /* xmlNodePtr current;            the node */
  1700.  
  1701.     xmlDocPtr output;            /* the resulting document */
  1702.     xmlNodePtr insert;            /* the insertion node */
  1703.  
  1704.     xmlXPathContextPtr xpathCtxt;    /* the XPath context */
  1705.     xsltTransformState state;        /* the current state */
  1706.  
  1707.     /*
  1708.      * Global variables
  1709.      */
  1710.     xmlHashTablePtr   globalVars;    /* the global variables and params */
  1711.  
  1712.     xmlNodePtr inst;            /* the instruction in the stylesheet */
  1713.  
  1714.     int xinclude;            /* should XInclude be processed */
  1715.  
  1716.     const char *      outputFile;    /* the output URI if known */
  1717.  
  1718.     int profile;                        /* is this run profiled */
  1719.     long             prof;        /* the current profiled value */
  1720.     int              profNr;        /* Nb of templates in the stack */
  1721.     int              profMax;        /* Size of the templtaes stack */
  1722.     long            *profTab;        /* the profile template stack */
  1723.  
  1724.     void            *_private;        /* user defined data */
  1725.  
  1726.     int              extrasNr;        /* the number of extras used */
  1727.     int              extrasMax;        /* the number of extras allocated */
  1728.     xsltRuntimeExtraPtr extras;        /* extra per runtime informations */
  1729.  
  1730.     xsltDocumentPtr  styleList;        /* the stylesheet docs list */
  1731.     void                 * sec;        /* the security preferences if any */
  1732.  
  1733.     xmlGenericErrorFunc  error;        /* a specific error handler */
  1734.     void              * errctx;        /* context for the error handler */
  1735.  
  1736.     xsltSortFunc      sortfunc;        /* a ctxt specific sort routine */
  1737.  
  1738.     /*
  1739.      * handling of temporary Result Value Tree
  1740.      * (XSLT 1.0 term: "Result Tree Fragment")
  1741.      */
  1742.     xmlDocPtr       tmpRVT;        /* list of RVT without persistance */
  1743.     xmlDocPtr       persistRVT;        /* list of persistant RVTs */
  1744.     int             ctxtflags;          /* context processing flags */
  1745.  
  1746.     /*
  1747.      * Speed optimization when coalescing text nodes
  1748.      */
  1749.     const xmlChar  *lasttext;        /* last text node content */
  1750.     unsigned int    lasttsize;        /* last text node size */
  1751.     unsigned int    lasttuse;        /* last text node use */
  1752.     /*
  1753.      * Per Context Debugging
  1754.      */
  1755.     int debugStatus;            /* the context level debug status */
  1756.     unsigned long* traceCode;        /* pointer to the variable holding the mask */
  1757.  
  1758.     int parserOptions;            /* parser options xmlParserOption */
  1759.  
  1760.     /*
  1761.      * dictionary: shared between stylesheet, context and documents.
  1762.      */
  1763.     xmlDictPtr dict;
  1764.     xmlDocPtr        tmpDoc; /* Obsolete; not used in the library. */
  1765.     /*
  1766.      * all document text strings are internalized
  1767.      */
  1768.     int internalized;
  1769.     int nbKeys;
  1770.     int hasTemplKeyPatterns;
  1771.     xsltTemplatePtr currentTemplateRule; /* the Current Template Rule */
  1772.     xmlNodePtr initialContextNode;
  1773.     xmlDocPtr initialContextDoc;
  1774.     xsltTransformCachePtr cache;
  1775.     void *contextVariable; /* the current variable item */
  1776.     xmlDocPtr localRVT; /* list of local tree fragments; will be freed when
  1777.                the instruction which created the fragment
  1778.                            exits */
  1779.     xmlDocPtr localRVTBase;
  1780.     int keyInitLevel;   /* Needed to catch recursive keys issues */
  1781. };
  1782.  
  1783. /**
  1784.  * CHECK_STOPPED:
  1785.  *
  1786.  * Macro to check if the XSLT processing should be stopped.
  1787.  * Will return from the function.
  1788.  */
  1789. #define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;
  1790.  
  1791. /**
  1792.  * CHECK_STOPPEDE:
  1793.  *
  1794.  * Macro to check if the XSLT processing should be stopped.
  1795.  * Will goto the error: label.
  1796.  */
  1797. #define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;
  1798.  
  1799. /**
  1800.  * CHECK_STOPPED0:
  1801.  *
  1802.  * Macro to check if the XSLT processing should be stopped.
  1803.  * Will return from the function with a 0 value.
  1804.  */
  1805. #define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
  1806.  
  1807. /*
  1808.  * The macro XML_CAST_FPTR is a hack to avoid a gcc warning about
  1809.  * possible incompatibilities between function pointers and object
  1810.  * pointers.  It is defined in libxml/hash.h within recent versions
  1811.  * of libxml2, but is put here for compatibility.
  1812.  */
  1813. #ifndef XML_CAST_FPTR
  1814. /**
  1815.  * XML_CAST_FPTR:
  1816.  * @fptr:  pointer to a function
  1817.  *
  1818.  * Macro to do a casting from an object pointer to a
  1819.  * function pointer without encountering a warning from
  1820.  * gcc
  1821.  *
  1822.  * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
  1823.  * This macro violated ISO C aliasing rules (gcc4 on s390 broke)
  1824.  * so it is disabled now
  1825.  */
  1826.  
  1827. #define XML_CAST_FPTR(fptr) fptr
  1828. #endif
  1829. /*
  1830.  * Functions associated to the internal types
  1831. xsltDecimalFormatPtr    xsltDecimalFormatGetByName(xsltStylesheetPtr sheet,
  1832.                            xmlChar *name);
  1833.  */
  1834. XSLTPUBFUN xsltStylesheetPtr XSLTCALL    
  1835.             xsltNewStylesheet    (void);
  1836. XSLTPUBFUN xsltStylesheetPtr XSLTCALL    
  1837.             xsltParseStylesheetFile    (const xmlChar* filename);
  1838. XSLTPUBFUN void XSLTCALL            
  1839.             xsltFreeStylesheet    (xsltStylesheetPtr style);
  1840. XSLTPUBFUN int XSLTCALL            
  1841.             xsltIsBlank        (xmlChar *str);
  1842. XSLTPUBFUN void XSLTCALL            
  1843.             xsltFreeStackElemList    (xsltStackElemPtr elem);
  1844. XSLTPUBFUN xsltDecimalFormatPtr XSLTCALL    
  1845.             xsltDecimalFormatGetByName(xsltStylesheetPtr style,
  1846.                          xmlChar *name);
  1847.  
  1848. XSLTPUBFUN xsltStylesheetPtr XSLTCALL    
  1849.             xsltParseStylesheetProcess(xsltStylesheetPtr ret,
  1850.                          xmlDocPtr doc);
  1851. XSLTPUBFUN void XSLTCALL            
  1852.             xsltParseStylesheetOutput(xsltStylesheetPtr style,
  1853.                          xmlNodePtr cur);
  1854. XSLTPUBFUN xsltStylesheetPtr XSLTCALL    
  1855.             xsltParseStylesheetDoc    (xmlDocPtr doc);
  1856. XSLTPUBFUN xsltStylesheetPtr XSLTCALL    
  1857.             xsltParseStylesheetImportedDoc(xmlDocPtr doc,
  1858.                         xsltStylesheetPtr style);
  1859. XSLTPUBFUN xsltStylesheetPtr XSLTCALL    
  1860.             xsltLoadStylesheetPI    (xmlDocPtr doc);
  1861. XSLTPUBFUN void XSLTCALL             
  1862.             xsltNumberFormat    (xsltTransformContextPtr ctxt,
  1863.                          xsltNumberDataPtr data,
  1864.                          xmlNodePtr node);
  1865. XSLTPUBFUN xmlXPathError XSLTCALL         
  1866.             xsltFormatNumberConversion(xsltDecimalFormatPtr self,
  1867.                          xmlChar *format,
  1868.                          double number,
  1869.                          xmlChar **result);
  1870.  
  1871. XSLTPUBFUN void XSLTCALL            
  1872.             xsltParseTemplateContent(xsltStylesheetPtr style,
  1873.                          xmlNodePtr templ);
  1874. XSLTPUBFUN int XSLTCALL            
  1875.             xsltAllocateExtra    (xsltStylesheetPtr style);
  1876. XSLTPUBFUN int XSLTCALL            
  1877.             xsltAllocateExtraCtxt    (xsltTransformContextPtr ctxt);
  1878. /*
  1879.  * Extra functions for Result Value Trees
  1880.  */
  1881. XSLTPUBFUN xmlDocPtr XSLTCALL        
  1882.             xsltCreateRVT        (xsltTransformContextPtr ctxt);
  1883. XSLTPUBFUN int XSLTCALL            
  1884.             xsltRegisterTmpRVT    (xsltTransformContextPtr ctxt,
  1885.                          xmlDocPtr RVT);
  1886. XSLTPUBFUN int XSLTCALL            
  1887.             xsltRegisterLocalRVT    (xsltTransformContextPtr ctxt,
  1888.                          xmlDocPtr RVT);
  1889. XSLTPUBFUN int XSLTCALL            
  1890.             xsltRegisterPersistRVT    (xsltTransformContextPtr ctxt,
  1891.                          xmlDocPtr RVT);
  1892. XSLTPUBFUN int XSLTCALL
  1893.             xsltExtensionInstructionResultRegister(
  1894.                          xsltTransformContextPtr ctxt,
  1895.                          xmlXPathObjectPtr obj);
  1896. XSLTPUBFUN int XSLTCALL
  1897.             xsltExtensionInstructionResultFinalize(
  1898.                          xsltTransformContextPtr ctxt);
  1899. XSLTPUBFUN void XSLTCALL
  1900.             xsltFreeRVTs        (xsltTransformContextPtr ctxt);
  1901. XSLTPUBFUN void XSLTCALL
  1902.             xsltReleaseRVT        (xsltTransformContextPtr ctxt,
  1903.                          xmlDocPtr RVT);
  1904. XSLTPUBFUN int XSLTCALL
  1905.             xsltTransStorageAdd    (xsltTransformContextPtr ctxt,
  1906.                          void *id,
  1907.                          void *data);
  1908. XSLTPUBFUN void * XSLTCALL
  1909.             xsltTransStorageRemove    (xsltTransformContextPtr ctxt,
  1910.                          void *id);
  1911.  
  1912. /*
  1913.  * Extra functions for Attribute Value Templates
  1914.  */
  1915. XSLTPUBFUN void XSLTCALL
  1916.             xsltCompileAttr        (xsltStylesheetPtr style,
  1917.                          xmlAttrPtr attr);
  1918. XSLTPUBFUN xmlChar * XSLTCALL
  1919.             xsltEvalAVT        (xsltTransformContextPtr ctxt,
  1920.                          void *avt,
  1921.                          xmlNodePtr node);
  1922. XSLTPUBFUN void XSLTCALL
  1923.             xsltFreeAVTList        (void *avt);
  1924.  
  1925. /*
  1926.  * Extra function for successful xsltCleanupGlobals / xsltInit sequence.
  1927.  */
  1928.  
  1929. XSLTPUBFUN void XSLTCALL
  1930.             xsltUninit        (void);
  1931.  
  1932. /************************************************************************
  1933.  *                                    *
  1934.  *  Compile-time functions for *internal* use only                      *
  1935.  *                                    *
  1936.  ************************************************************************/
  1937.  
  1938. #ifdef XSLT_REFACTORED  
  1939. XSLTPUBFUN void XSLTCALL
  1940.             xsltParseSequenceConstructor(
  1941.                          xsltCompilerCtxtPtr cctxt,
  1942.                          xmlNodePtr start);
  1943. XSLTPUBFUN int XSLTCALL
  1944.             xsltParseAnyXSLTElem    (xsltCompilerCtxtPtr cctxt,
  1945.                          xmlNodePtr elem);
  1946. #ifdef XSLT_REFACTORED_XSLT_NSCOMP
  1947. XSLTPUBFUN int XSLTCALL
  1948.             xsltRestoreDocumentNamespaces(
  1949.                          xsltNsMapPtr ns,
  1950.                          xmlDocPtr doc);
  1951. #endif
  1952. #endif /* XSLT_REFACTORED */
  1953.  
  1954. /************************************************************************
  1955.  *                                    *
  1956.  *  Transformation-time functions for *internal* use only               *
  1957.  *                                    *
  1958.  ************************************************************************/
  1959. XSLTPUBFUN int XSLTCALL
  1960.             xsltInitCtxtKey        (xsltTransformContextPtr ctxt,
  1961.                          xsltDocumentPtr doc,
  1962.                          xsltKeyDefPtr keyd);
  1963. XSLTPUBFUN int XSLTCALL
  1964.             xsltInitAllDocKeys    (xsltTransformContextPtr ctxt);
  1965. #ifdef __cplusplus
  1966. }
  1967. #endif
  1968.  
  1969. #endif /* __XML_XSLT_H__ */
  1970.  
  1971.